// 获取题目类型标签样式
export const getTypeTag = (type) => {
    const types = {
        10001: "success",
        10002: "warning",
        10003: "info",
        10004: "primary",
        10005: "danger",
    };
    return types[type] || "info";
};

// 获取题目类型文本
export const getTypeText = (type) => {
    const types = {
        10001: "单选题",
        10002: "多选题",
        10003: "判断题",
        10004: "填空题",
        10005: "简答题",
    };
    return types[type] || "未知类型";
};

// 题目类型选项
export const typeOptions = [
    { label: "单选题", value: 10001 },
    { label: "多选题", value: 10002 },
    { label: "判断题", value: 10003 },
    { label: "填空题", value: 10004 },
    { label: "简答题", value: 10005 },
];

// 难度选项
export const difficultyOptions = [
    { label: "简单", value: 1 },
    { label: "较简单", value: 2 },
    { label: "中等", value: 3 },
    { label: "较难", value: 4 },
    { label: "困难", value: 5 },
];

export const getExamProcessStatusByDateRange = (startDateStr, endDateStr) => {
    // 将输入的日期字符串转换为 Date 对象
    const startDate = new Date(startDateStr);
    const endDate = new Date(endDateStr);
    const now = new Date();

    // 检查日期是否有效（避免 NaN）
    if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
        console.error("日期格式不正确，请使用 'YYYY-MM-DD HH:mm' 格式");
        return false;
    }

    // 比较时间戳（毫秒）
    if (now < startDate) {
        return "未开始";
    } else if (now >= startDate && now <= endDate) {
        return "考试中";
    } else return "已结束";
};

// 获取状态类型
export const getExamProcessStatusType = (status) => {
    const types = {
        "未开始": "info",
        "考试中": "success",
        "已结束": "warning",
    };
    return types[status] || "info";
};

// 获取考试状态标签样式
export const getStatusTag = (statusId) => {
    const status = {
        10001: "info",
        10002: "warning",
        10003: "danger",
        10004: "primary",
        10005: "success",
    };
    return status[statusId] || "info";
};

// 获取考试状态文本
export const getStatusText = (statusId) => {
    const status = {
        10000: "未报名",
        10001: "已报名",
        10002: "缺考",
        10003: "考试中",
        10004: "已交卷",
        10005: "已评分",
    };
    return status[statusId] || "未知类型";
};

// 获取默认分值
export const getDefaultScoreByType = (typeId) => {
    switch (typeId) {
        case 10001: // 单选题
            return 5;
        case 10002: // 多选题
            return 6;
        case 10003: // 判断题
            return 2;
        case 10004: // 填空题
            return 3;
        case 10005: // 简答题
            return 10;
        default:
            return 5;
    }
};